package com.asion.vmovie.app;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.asion.vmovie.db.DaoMaster;
import com.asion.vmovie.db.DaoSession;
import com.asion.vmovie.db.searchDao;

/**
 * Created by asion on 16-10-17.
 */

public class MyApp extends Application {

    public static Context context;
    private static SQLiteDatabase db;
    private static DaoMaster daoMaster;
    private static DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        context=this;
    }

    public static searchDao getSearchDao(){
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context,"VMovie_db",null);
        db = helper.getWritableDatabase();
        daoMaster = new DaoMaster(db);
        daoSession =daoMaster.newSession();
        return daoSession.getSearchDao();
    }
}
